package com.itheima.udp;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;

public class SendDemo {
    public static void main(String[] args) throws IOException {
        DatagramSocket ds = new DatagramSocket();

        byte[] bytes = "Hello Java".getBytes();
        DatagramPacket dp = new DatagramPacket(
                bytes,//发送这个字节数组的数据
                bytes.length,//发送的数据是数组的长度
                InetAddress.getByName("127.0.0.1"),//确定自己要发送的IP
                10086);//确定端口号

        //发送
        ds.send(dp);
        //关闭
        ds.close();
    }
}
